﻿using System;

class TrippleRotationOfDigits
{
    static void Main()
    {
        string consoleInput = Console.ReadLine();
        int number = int.Parse(consoleInput);

        string digit = "";

        if (number > 0 && number < 10)
        {
            Console.WriteLine(number);
        }
        else
        {
            for (int i = 0; i < 3; i++)
            {
                digit = Convert.ToString(consoleInput[consoleInput.Length - 1]);
                number = number / 10;
                consoleInput = digit + Convert.ToString(number);
                number = int.Parse(consoleInput);
                if (number > 0 && number < 10)
                {
                    break;
                }
            }
            Console.WriteLine(number);
        }
        
    }
}
